package com.yulang.springbootnetty.netty;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;


/**
 * 初始化器当channel注册后会执行里面相应的初始化方法
 */
public class HelloServerInit extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        //获取管道
        ChannelPipeline pipeline = socketChannel.pipeline();
        //添加http助手类（用于http请求的编解码器）
        pipeline.addLast(new HttpServerCodec());
        //添加自定义的助手类
        pipeline.addLast(new CoustomHandler());
    }
}
